package org.example.gui.panel;

import org.example.gui.listener.BackupListener;
import org.example.gui.listener.RecoverListener;
import org.example.util.ColorUtil;
import org.example.util.GUIUtil;

import javax.swing.*;

/**
 * 界面类 BackupAndRecoverPanel 备份、导出Excel、恢复
 */

public class BackupAndRecoverPanel extends WorkingPanel {
    public static BackupAndRecoverPanel instance = new BackupAndRecoverPanel();
    private final JButton bBackup = new JButton("备份");
    private final JButton bExport = new JButton("导出Excel");
    private final JButton bRecover =new JButton("恢复");

    public BackupAndRecoverPanel() {
        GUIUtil.setColor(ColorUtil.blueColor, bBackup, bExport, bRecover);
        this.add(bBackup);
        this.add(bExport);
        this.add(bRecover);
        addListener();
    }


    @Override
    public void updateData() {

    }

    @Override
    public void addListener() {
        BackupListener dbListener = new BackupListener(BackupListener.DB);
        bBackup.addActionListener(dbListener);

        BackupListener xlsxListener = new BackupListener(BackupListener.XLSX);
        bExport.addActionListener(xlsxListener);

        RecoverListener listener = new RecoverListener();
        bRecover.addActionListener(listener);
    }
}